package com.spring.cloud.client.controller;

import com.spring.cloud.client.service.RpcInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author li gang
 */
@RestController
public class Controller {

    @Autowired
    private RpcInformation service;

    @RequestMapping(value = "/")
    public String healthCheck() {
        return "consumer is ok";
    }

    @RequestMapping(value = "/rpc_get")
    public String getInfo(@RequestParam(value = "key") String key) {
        return this.service.getInfo(key);
    }

    @RequestMapping(value = "/rpc_save")
    public void saveInfo(@RequestParam(value = "key") String key, @RequestParam(value = "value") String value) {
        this.service.saveInfo(key, value);
    }


    @RequestMapping(value = "/rpc_hello_world")
    public String helloWorld() {
        return this.service.getHelloInfo();
    }
}
